<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2020-07-02
  Time: 15:23
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=utf-8" %>
<%@page import="java.lang.*" %>
<%@ page import="entity.Movie" %>
<%@ page import="java.util.List" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <base href="<%=basePath%>">
    <title>查询结果</title>
    <link rel="stylesheet" href="css/mainStyle.css" type="text/css" media="all">
</head>
<%
    response.setContentType("text/html; charset=UTF-8");
    response.setCharacterEncoding("utf-8");
    request.setCharacterEncoding("utf-8");//防止中文乱码
    List<Movie> list = (List<Movie>) request.getAttribute("list");
    System.out.println("--movieResulr---" + list.isEmpty());

%>
<body>
<ul>
    <li><a href="index.jsp">电影列表</a></li>
    <li><a href="scoreBar.jsp" target="_blank">电影平均分</a></li>
    <li><a class="active" href="#">查询结果</a></li>
</ul>
<div class="container">
    <!-- 查询按钮 -->
    <div class="Search">
        <form action="MoviesServlet" method="post">
            <div class="formStyle">
                <div class="con">
                <span class="radio_box"><input type="radio" id="radio_1" name="type" value="1" checked=""><label
                        for="radio_1"></label><em style="font-style: normal">前匹配</em></span>
                    <span class="radio_box"><input type="radio" id="radio_2" name="type" value="2"><label
                            for="radio_2"></label><em style="font-style: normal">后匹配</em></span>
                    <span class="radio_box"><input type="radio" id="radio_3" name="type" value="3"><label
                            for="radio_3"></label><em style="font-style: normal">模糊过滤</em></span>
                </div>
                <div class="flex">
                    <input type="text" name="movieName" id="movieName" placeholder="请输入电影关键字" required maxLength="20">
                    <input type="submit" value="查询电影" class="Search_Button">
                </div>
            </div>
        </form>
    </div>
    <!-- 所有电影信息表: -->
    <div class="StaffInfo_One">
        <%
            if (!list.isEmpty()) {
        %>
        <table border="1">
            <tr>
                <td>电影编号</td>
                <td>电影片名</td>
                <td>电影类型</td>
                <td>实时评分</td>
            </tr>
            <%
                for (int i = 0; i < list.size(); i++) {
            %>
            <tr>
                <td><%=list.get(i).getMovieId()%>
                </td>
                <td><%=list.get(i).getTitle()%>
                </td>
                <td><%=list.get(i).getGenres()%>
                </td>
                <td style="text-align: center;">
                    <a href="dynamicRating.jsp?movieID=<%=list.get(i).getMovieId()%>">
                        <img src="../images/rat.jpg" style="width: 25px;height: 25px;"/>
                    </a>
                </td>
            </tr>
            <%
                }
            %>
        </table>
        <%
        } else {
        %>
        <h3>没有查到数据!</h3>
        <%
            }
        %>

    </div>
    <div class="backdiv">
        <button class="backbtn" onclick="window.location.href='index.jsp'">返回电影列表</button>
    </div>
</div>
</body>
</html>
